Using WPF Screen Elements During Runtime

You can use captured screen element types in your project. Below is an example of how to work with properties and functions of the WPF General screen element. The Monitor application is used during runtime in the example.

The WPF General screen element type is the basic type, meaning all other WPF screen element types inherit properties, functions, and events from this property, and may have their own additional functionality.

In this example, the functionality of the WPF General screen element is used to demonstrate how to work with the WPF screen element.

To interact with WPF screen elements during runtime:

1. Run the project and select Monitor. See also Running the Monitor.
2. Click the Screen Element tab. A full hierarchy of the captured WPF screen element is displayed (including hidden captures). Select the relevant WPF screen element in the tree on the left. The list of properties of the screen element is enabled in the Properties tab on the right:

In Monitor only properties of simple types are listed (Boolean, DateTime, Decimal, Number, Text). To get properties of other types (List type, Screen Element Rectangle type and other Libarary screen element types), you must bind them with business entities in the project.

3. Open the Functions tab.

The functions of the screen element are available in the Available Functions drop-down list:

Monitor displays only properties of simple types. The functions of other types, such as List of PO, PO and CtrlPO, are not shown. To use functions not shown in Monitor, you must define them in the Business Entities module in Real-Time Designer.

4. To run a function, select it from the Available Functions drop-down list, set the function parameters (if applicable), then click Invoke.

Simple Return Type Functions

The following simple return type functions are available in Monitor:

Bring to Front: Moves the WPF object to the top of the stacking order (brings the object to the front).

Set Focus: Sets the focus on the selected screen element in the WPF application.

Double Click on Point: Double-clicks a point on a screen element, specified by the x and y parameters.

Right Click on Point: Right-click a point on a screen element, specified by the x and y parameters.

Refresh: Destroys and then creates the selected screen element.

Set Property: Sets the value of a property, specified by the propName and propValue parameters.

propName: The name of the WPF object’s attribute. The value of this parameter is case-sensitive.

propValue: The value of the WPF object’s attribute.

Get Property: Gets the value of a property specified by the propName parameter. The value of this parameter is case-sensitive.

Locate: Locates the selected screen element in the WPF application

Complex Return Type Functions

The following complex return type functions are available in Monitor:

  • Activate and Lock Instance: Locks a specific screen element and makes it the active element. When you apply this function, the screen element itself and all its parent screen elements in the hierarchy are locked. For example, if you have multiple instances of an application, and at the beginning of each interaction you want to connect only to a single relevant instance and stay connected until the interaction is complete, you can use the Activate And Lock Instance function at the beginning of the interaction and then use the Unlock Active Instance function to unlock the active instance when the interaction is complete.

  • Destroy and Refresh: Validates the objects beginning from the level of the currently selected screen element in the hierarchy. The process destroys any object that no longer exists, and attempts to recognize new objects and all their child objects down the hierarchy.

  • Evaluate: Runs the script defined in the script parameter on the selected screen element.

  • Execute Addon Function: Executes the add-on function defined in the Name parameter on the selected screen element.

  • Execute Command: Executes a command on the selected screen element. For this function, you need to specify the Method, Class, and Assembly of the command you want to execute.

  • Get Children Count: Returns the number of children of the selected screen element.

  • Get Children Count by ClassName: Returns the number of children of the selected element in the class defined by the ClassName parameter.

  • Get Class Name: Returns the class name of the selected screen element.

  • Get Enumerator: Returns the enumerating physical object. You can use it with every screen element that has an enumerator as a control (process is excluded because it doesn’t have an enumerator and usually top level window is excluded because its enumerator is the process).

  • Get Instance: Returns the first recognized physical object of the screen element from the process defined by the Process ID parameter.

  • Get Instances: Returns all the recognized physical objects of the screen element from the process defined by the Process ID parameter.

  • Get Instance by Parent: Returns the first recognized physical object of the screen element for a parent object defined by the Window Handle parameter, where this value is the enumerator (parent) Window Handle.

  • Recognize Children: Recognizes the children of the selected screen element.

  • Unlock Active Instance: Unlocks the active instance locked by the Activate And Lock Instance function, and therefore must be applied on the same instance that was locked.

  • Validate Children: Validates the children of the selected screen element.

Instances of CtrlPO type – every screen element that is not a Process screen element. Instances of PO type – every screen element (i.e., CtrlPO + Process).